package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DishesSerivce;
import com.ruoyi.system.service.IDishesSerivceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 菜品取拿Controller
 * 
 * @author ruoyi
 * @date 2021-06-17
 */
@RestController
@RequestMapping("/system/dish")
public class DishesSerivceController extends BaseController
{
    @Autowired
    private IDishesSerivceService dishesSerivceService;

    /**
     * 查询菜品取拿列表
     */
//    @PreAuthorize("@ss.hasPermi('system:serivce:list')")
    @GetMapping("/list")
    public TableDataInfo list(DishesSerivce dishesSerivce)
    {
        startPage();
        List<DishesSerivce> list = dishesSerivceService.selectDishesSerivceList(dishesSerivce);
        return getDataTable(list);
    }

    /**
     * 导出菜品取拿列表
     */
//    @PreAuthorize("@ss.hasPermi('system:serivce:export')")
    @Log(title = "菜品取拿", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DishesSerivce dishesSerivce)
    {
        List<DishesSerivce> list = dishesSerivceService.selectDishesSerivceList(dishesSerivce);
        ExcelUtil<DishesSerivce> util = new ExcelUtil<DishesSerivce>(DishesSerivce.class);
        return util.exportExcel(list, "serivce");
    }

    /**
     * 获取菜品取拿详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:serivce:query')")
    @GetMapping(value = "/{disId}")
    public AjaxResult getInfo(@PathVariable("disId") Long disId)
    {
        return AjaxResult.success(dishesSerivceService.selectDishesSerivceById(disId));
    }

    /**
     * 新增菜品取拿
     */
//    @PreAuthorize("@ss.hasPermi('system:serivce:add')")
    @Log(title = "菜品取拿", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DishesSerivce dishesSerivce)
    {
        return toAjax(dishesSerivceService.insertDishesSerivce(dishesSerivce));
    }

    /**
     * 修改菜品取拿
//     */
//    @PreAuthorize("@ss.hasPermi('system:serivce:edit')")
    @Log(title = "菜品取拿", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DishesSerivce dishesSerivce)
    {
        return toAjax(dishesSerivceService.updateDishesSerivce(dishesSerivce));
    }

    /**
     * 删除菜品取拿
     */
//    @PreAuthorize("@ss.hasPermi('system:serivce:remove')")
    @Log(title = "菜品取拿", businessType = BusinessType.DELETE)
	@DeleteMapping("/{disIds}")
    public AjaxResult remove(@PathVariable Long[] disIds)
    {
        return toAjax(dishesSerivceService.deleteDishesSerivceByIds(disIds));
    }
}
